<#include "/common/head.ftl">
<@head>


<div class="container">
       <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron">
        <h1 id="next_expect"></h1>

        <p>距离开奖还有 <span id="next_expect_long" ></span> 秒</p>

        <a class="btn  btn-primary  " href="/bjpk10/history_list" role="button">历史数据</a>

      </div>

</div>



<div class="container"  >
<table class="table">
  <caption>开奖结果</caption>
  <thead>
    <tr>
      <th>期数</th>
      <th>结果</th>
      <th>状态</th>
      </tr>
  </thead>
  <tbody id="tbody"></tbody>
</table>



</div>




<@js>
//-------

function update_next_expect_long(){
 var next_expect_long=$("#next_expect_long");
 var time=Number(next_expect_long.html()) - 1;
     next_expect_long.html(time);
     if(time<=0){
        list_lately_expect()
        load();
     }else{
        setTimeout(update_next_expect_long,1000);
     }
}

function load(){
    $.post("next_expect", { "t": Math.random() },
       function(data){
         console.log(data); //  2pm
         $("#next_expect").html("第"+data.data.expect+"期");
         $("#next_expect_long").html(data.data.endLong);
         setTimeout(update_next_expect_long,1000);
       }, "json");
}


function list_lately_expect(){
    $("#tbody").load('list_lately_expect?'+Math.random());
}

list_lately_expect();
load();

function shuaexpect(expect){
    $.post("get_expect_info", {code:"bjpk10","expect":expect, "t": Math.random() },
       function(data){
         console.log(data); //  2pm
         if(data.data==2){
            list_lately_expect();
         }else{
            setTimeout(function(){shuaexpect(expect)}, 5000);
         }
       }, "json");

}



</@js>

</@head>